package main

import "fmt"

func main() {
	/*
		创建方式
	*/

	var arr1 [4]int
	arr1[0] = 1
	arr1[1] = 2
	arr1[2] = 3
	arr1[3] = 4

	fmt.Println(arr1, len(arr1), cap(arr1))
	//len  实际存储的数据量
	//cap  容器中能够存储的最大数量
	//由于数组是定长的，所以 长度和容量相同

	var a = [4]int{1: 3, 2: 3}
	var b [4]int
	var c = [4]int{1, 2, 3, 4}
	fmt.Println(a, b, c)

	var d = [4]string{1: "你好", 2: "haha"} //剩下两个是空字符串
	fmt.Println(d)

	f := [...]int{1, 2, 3, 4, 5, 6}
	fmt.Println(f)

	g := [...]int{1, 2, 3, 4}
	var h [10]int
	fmt.Println(g, h)

	//for range  遍历    _可以用来舍弃
	for i, v := range d {
		fmt.Println(i, v)
	}

	for _, v := range d {
		fmt.Println(v)
	}

	for i, _ := range d {
		fmt.Println(i)
	}

	//数组是值传递
	d1 := d
	fmt.Println(d, d1)
	d1[1] = "哈哈哈！！！！！！"
	fmt.Println(d, d1)

	//fmt.Println(f==g)     // 长度不一样的数组也不是同一种类型  invalid operation: f == g (mismatched types [6]int and [4]int)
}
